package cn.kgc.spring.day04.entity;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author 课工场
 * @date 2024/7/16
 * @description
 */
@Component
// @Scope("prototype")  //  作用域标签
public class Student {

    @Value("1")
    private Integer id;
    @Value("tom")
    private String studentName;


    public Student(Integer id, String studentName) {
        this.id = id;
        this.studentName = studentName;
    }

    public Student() {
        System.out.println("-----------Student()----------");
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        System.out.println("-----------setId(Integer id)----------");
        this.id = id;
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }


    // 初始化方法
    @PostConstruct
    public void  init(){
        System.out.println("-----------init()-------------");
    }

    //销毁方法
    @PreDestroy
    public void  destroy(){
        System.out.println("-----------destroy()-------------");
    }


    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", studentName='" + studentName + '\'' +
                '}';
    }
}
